import type { IFieldProps, IConfigProps } from '@/components/sofastui/AdvancedTable/interface'
import type { FormRule } from '@form-create/element-ui'

export const fields: IFieldProps[] = [
  {
    label: 'ID',
    prop: 'id',
    minWidth: 60,
    import: true,
    export: true,
    search: false,
    select: false,
  },
  {
    label: '数据源ID',
    prop: 'dataSourceId',
    minWidth: 80,
    import: true,
    export: true,
    search: true,
    select: false,
  },
  {
    label: '实际表名',
    prop: 'tableName',
    minWidth: 120,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '表名称（别名）',
    prop: 'name',
    minWidth: 100,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '表类型',
    prop: 'type',
    minWidth: 120,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '表配置',
    prop: 'config',
    minWidth: 120,
    import: true,
    export: true,
    search: false,
  },
  {
    label: '状态',
    prop: 'status',
    minWidth: 80,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '描述',
    prop: 'description',
    minWidth: 100,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '创建时间',
    prop: 'createdAt',
    minWidth: 120,
    import: true,
    export: true,
    search: false,
    select: false,
  },
  {
    label: '修改时间',
    prop: 'updatedAt',
    minWidth: 120,
    import: true,
    export: true,
    search: false,
    select: false,
  },
]

export const config: IConfigProps = {
  name: 'powJobTable',
  rowKey: 'id',
  url: '/api/dev/data_table',
  selection: true,
  add: true,
  delete: true,
  expand: true,
  showIndex: true,
  import: true,
  export: true,
  search: true,
  advancedSearch: true,
  refresh: true,
  settings: true,
  operate: true,
}

export const formRules: FormRule = [
  {
    type: 'select',
    field: 'type',
    title: '表类型',
    effect: {
      fetch: '',
    },
    $required: true,
    props: {
      multiple: false,
    },
    value: 'physical',
    options: [
      {
        label: '物理表',
        value: 'physical',
      },
      {
        label: '虚拟表',
        value: 'virtual',
      },
    ],
    _fc_id: 'id_Fenemcm13c5pajc',
    name: 'ref_Fej0mcm13c5pakc',
    display: true,
    hidden: false,
    _fc_drag_tag: 'select',
  },
  {
    type: 'input',
    field: 'tableName',
    title: '实际表名',
    $required: true,
    _fc_id: 'id_Fuu1mcm11l9aadc',
    name: 'ref_Fn1qmcm11l9aaec',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'input',
    field: 'name',
    title: '表名称（别名）',
    $required: true,
    _fc_id: 'id_Fuu1mcm11l1aadc',
    name: 'ref_Fn1qmcm11l2aaec',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'input',
    field: 'config',
    title: '表配置',
    $required: true,
    props: {
      type: 'textarea',
    },
    _fc_id: 'id_Fexkmcm16djqavc',
    name: 'ref_F6bfmcm16djqawc',
    display: true,
    hidden: false,
    _fc_drag_tag: 'textarea',
  },
  {
    type: 'radio',
    field: 'status',
    title: '状态',
    effect: {
      fetch: '',
    },
    $required: true,
    value: 1,
    options: [
      {
        label: '启用',
        value: 1,
      },
      {
        label: '禁用',
        value: 0,
      },
    ],
    _fc_id: 'id_Foj7mcm1743pb0c',
    name: 'ref_F6n5mcm1743pb1c',
    display: true,
    hidden: false,
    _fc_drag_tag: 'radio',
  },
  {
    type: 'input',
    field: 'description',
    title: '描述',
    $required: false,
    props: {
      type: 'textarea',
      maxlength: 200,
      showWordLimit: true,
    },
    _fc_id: 'id_Fg8mmcm182clb5c',
    name: 'ref_Fr7emcm182clb6c',
    display: true,
    hidden: false,
    _fc_drag_tag: 'textarea',
  },
]
